package com.beta.cust.bind.datasync.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.beta.cust.bind.datasync.constant.BusinessConstant;
import com.beta.cust.bind.datasync.dto.CrmCustDetailReq;
import com.beta.cust.bind.datasync.mapper.CrmCustDetailMapper;
import com.beta.cust.bind.datasync.mapper.entity.CrmCustDetail;
import com.beta.cust.bind.datasync.service.ICrmCustDetailService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 客户(CRM)信息表 服务实现类
 * </p>
 *
 * @author pcc
 * @since 2024-03-12
 */
@Service
public class CrmCustDetailServiceImpl extends ServiceImpl<CrmCustDetailMapper, CrmCustDetail> implements ICrmCustDetailService {

    @Override
    public IPage<CrmCustDetail> selectPage(CrmCustDetailReq req) {
        Page<CrmCustDetail> page = new Page<>(req.getCurrentPage(), req.getPageSize(), false);//不要查询总数，影响性能
        return baseMapper.selectPage(page, new LambdaQueryWrapper<CrmCustDetail>()
                .eq(CrmCustDetail::getDelFlag, BusinessConstant.IS_NOT_DEL_FLAG)
                .gt(null != req.getId(), CrmCustDetail::getId, req.getId())
                .orderByAsc(CrmCustDetail::getId));//一定要按照id进行升级排序
    }
}
